//
//  HMDealTool.m
//
//  Created by apple on 14-8-16.
//  Copyright (c) 2014年 heima. All rights reserved.
//  网络层

#import "MSDealTool.h"
#import "MSAPITool.h"


@interface MSDealTool ()

@end


@implementation MSDealTool
/**
 *  搜索团购
 *
 *  @param param   请求数据对象（商家）
 *  @param success
 *  @param failure
 */
+ (void)findDeals:(MSFindDealsParam *)param success:(void (^)(MSFindDealsResult *))success failure:(void (^)(NSError *))failure
{
    
    [[MSAPITool sharedAPITool] request:@"v1/deal/find_deals" params:param.keyValues success:^(id json) {
        if (success) {
            //将json数据转化为model
            MSFindDealsResult *obj = [MSFindDealsResult objectWithKeyValues:json];
            success(obj);
        }
    } failure:failure];
}
/**
 *  搜索商户
 *
 *  @param param
 *  @param success
 *  @param failure
 */

+(void)findBusniss:(FindBusnissParam *)param success:(void (^)(FindBusnissResult *result))success failure:(void (^)(NSError *error))failure
{
    [[MSAPITool sharedAPITool] request:@"v1/business/find_businesses" params:param.keyValues success:^(id json) {
            FindBusnissResult *obj = [FindBusnissResult objectWithKeyValues:json];
            success(obj);
    } failure:failure];
}
/**
 *  获得指定商户的团购信息
 *
 *  @param param   参数
 *  @param success 成功结果
 *  @param failure 失败处理
 */
+(void)findBusnissSingle:(FindBusnissSingleParam *)param success:(void (^)(FindBusnissSingleResult *result))success failure:(void (^)(NSError *error))failure
{
    [[MSAPITool sharedAPITool]request:@"v1/business/get_single_business" params:param.keyValues success:^(id json) {
        //将结果转化为模型
        FindBusnissSingleResult *obj = [FindBusnissSingleResult objectWithKeyValues:json];
        success(obj);
    } failure:failure];
}

/**
 * 获取指定团购信息
 *
 *  @param param   <#param description#>
 *  @param success <#success description#>
 *  @param failure <#failure description#>
 */
+ (void)getSingleDeal:(MSGetSingleDealParam *)param success:(void (^)(MSGetSingleDealResult *result))success failure:(void (^)(NSError *error))failure
{
    [[MSAPITool sharedAPITool] request:@"v1/deal/get_single_deal" params:param.keyValues success:^(id json) {
        if (success) {
            MSGetSingleDealResult *obj = [MSGetSingleDealResult objectWithKeyValues:json];
            success(obj);
        }
    } failure:failure];
}
@end
